package com.service;

import com.dao.LoginLogDao;
import com.dao.UserDao;
import com.model.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by shazhengbo on 2017/3/2.
 */
@Service
public class UserService {

    @Autowired
    private UserDao userDao;

    @Autowired
    private LoginLogDao loginLogDao;

    public boolean hasMatchUser(String userName, String password) {
        int matchUser = userDao.getMatchCount(userName, password);
        if (matchUser > 0)
            return true;
        else

            return false;
    }

    public Users finUserByUserName(String userName){
        return  userDao.finUserByUserName(userName);
    }

    @Transactional
    public void loginSuccess(Users users){
        loginLogDao.insertLoginLog(users);
        userDao.updateUserInfo(users);

    }
}
